import React,{useEffect,useState} from 'react';
import { IRouteComponentProps } from 'umi'
import {useModel} from 'umi';
import Type from '../../components/typeList'
import Content from '../../components/content'
const Cart: React.FC<IRouteComponentProps> = ({match,history}) => {
    let {getNav,getGood} = useModel('typelist', model=>({getNav:model.getNav,getGood:model.getGood}));
    let [start,getStart] = useState([])
    let [nav,changeNav] = useState([''])
    let [footConent,changFoot] = useState([])
    useEffect( () => {
        navClick();
      }, []);
   const navClick = async () =>{
      let res =   await getNav(match.params.id);
     // console.log(res.data.brotherCategory,'看看',res.data.brotherCategory[0].id);
      getStart(res.data.brotherCategory[0].id)
      changeNav(res.data.brotherCategory)
      let result = await getGood(res.data.brotherCategory[0].id)
      console.log(result.data.data,999)
      changFoot(result.data.data)
   }
   async function changId(id:string){
      let result = await getGood(id);
      // console.log(222,result)
      changFoot(result.data.data)
    }
    async function his(id:string) {
        console.log(id,9090) 
        history.push(`/goodsList/`+ id) 
    }
  return (
    <div>
        <Type nav={nav} changIn={changId} />
        <Content changFoot = {footConent} history = {his} />
    </div>
  );
} 
export default Cart;
        
